package com.suxin.minio.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Tang
 * @classname MinIoConfig
 * @description [  ]
 * @date 2021/3/10 23:13
 */
@Configuration
public class MinIoConfig {

    @Bean
    @ConfigurationProperties(value = "minio")
    public MinIoModel minIoModel() {
        return new MinIoModel();
    }

    @Bean
    public MinioClient minioClient(@Autowired MinIoModel minIoModel) {
        return MinioClient.builder()
                .credentials(minIoModel.getAccess(), minIoModel.getSecret())
                .endpoint(minIoModel.getUrl())
                .build();
    }

}